<template>
	<view class="page page-fill">
	     <form @submit="submitBirthday" class="from">
			 <picker
			  class="picker"
			  mode = date
			  start = "1950-1-1"
			  end  = "2050-1-1"
			  @change = "changeBirthday"
			 >
			 {{birthday}}	 
			 </picker>
	     	<button class="btn" form-type="submit" type="primary">提交</button>
	     </form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				birthday:'',
			}
		},
		onLoad(params){
		    this.birthday = params.birthday;
		},
		methods: {
			submitBirthday(){
				var userInfo =  uni.getStorageSync('globalInfo');
								    uni.showLoading();
									uni.request({
										url:this.serverUrl + "/user/modifyUserinfo?qq=3316368400",
										header:{
											"headerUserId":userInfo.id,
											"headerUserToken":userInfo.userUniqueToken
										},
										data:{
											"userId": userInfo.id,
											"birthday":this.birthday
										},
										method:'POST',
				                      success:(res)=>{
											 if(res.data.status===200){
												  uni.setStorageSync("globalInfo",res.data.data)
												  uni.navigateBack({
												  	delta:1
												  })
											 }else if(res.data.status ==500 ||  res.data.status == 503 ){
												    uni.showToast({
												    	title:'修改生日失败',
												    }) 
											 }
										 },
										 complete:()=>{
											 uni.hideLoading()
										 }
									})
			},
			changeBirthday(e){
			   var date = e.detail.value;
			       this.birthday = date;
			
			}
		}
	}
</script>

<style>
 .picker{
	 height: 100upx;
	 padding: 0 40upx;
	 margin-top: 20upx;
	 font-size:18px;
	 line-height: 100upx;
	
 }
 .btn{
	 width: 90%;
	 margin-top: 40upx;
 }
</style>
